﻿using System;
using System.Collections;
using System.Windows.Controls;

namespace Rio.Framework.Pages.UserControls
{
    public class ObservableCombobox : ComboBox
    {
        public delegate void ItemsSourceChangedHandler(object sender, EventArgs e);
        
        public event ItemsSourceChangedHandler ItemsSourceChanged;
        
        public new IEnumerable ItemsSource
        {
            get { return base.ItemsSource; }
            set
            {
                base.ItemsSource = value;
                EventArgs e = new EventArgs();
                OnItemsSourceChanged(e);
            }
        }

        protected virtual void OnItemsSourceChanged(EventArgs e)
        {
            if (ItemsSourceChanged != null)
            {
                ItemsSourceChanged(this, e);
            }
        }
    }
}